# Monarc makefile

CC  = gcc
AS  = gcc
LD  = ld
AR  = ar
SED = sed
PL = perl


INCL = \
	-Iinclude \
	-I. \

DEFINES = \

C_OPT = -Wall -O3 -mno-stack-arg-probe -ffreestanding -nostartfiles -nodefaultlibs -nostdlib -nostdinc $(INCL) $(DEFINES)
OC_OPT = -Wall -O3 -mno-stack-arg-probe -ffreestanding -nostartfiles -nodefaultlibs -nostdlib -nostdinc $(INCL) $(DEFINES)

CC_OPT = -Wall -O3 -mno-stack-arg-probe -nostartfiles -fno-builtin -nodefaultlibs -nostdlib -nostdinc $(INCL) $(DEFINES)
OCC_OPT = -Wall -O3 -mno-stack-arg-probe -nostartfiles -fno-builtin -nodefaultlibs -nostdlib -nostdinc $(INCL) $(DEFINES)

MKDIR = mkdir
CP = cp
CAT = cat
RM = rm -f

c_sources = \
	console.c \
	printf.c \
	hash.c \
	string/strbase.c \
	string/string.c \
	string/strncat.c \
	string/strrchr.c \
	string/strstr.c \
	stdlib/random.c \
	stdlib/stdlib.c \
	stdlib/strtod.c \
	stdlib/strtoi.c \
	stdlib/strtol.c \
	stdlib/strtou.c \
	stdlib/strtoul.c \
	ioformat/sprintf.c \
	ioformat/sscanf.c \
	ioformat/gcvt.c \
	ioformat/ecvt.c \
	ioformat/fcvt.c \
	ioformat/ucvt.c \
	machine/infinity.c \
	machine/extra.c \
	msun/src/e_acosf.c \
	msun/src/e_acosh.c \
	msun/src/e_acoshf.c \
	msun/src/e_asinf.c \
	msun/src/e_atan2f.c \
	msun/src/e_atanh.c \
	msun/src/e_atanhf.c \
	msun/src/e_cosh.c \
	msun/src/e_coshf.c \
	msun/src/e_expf.c \
	msun/src/e_fmodf.c \
	msun/src/e_gamf1.c \
	msun/src/e_gamma.c \
	msun/src/e_gamma_.c \
	msun/src/e_gammaf.c \
	msun/src/e_hypot.c \
	msun/src/e_hypotf.c \
	msun/src/e_j0.c \
	msun/src/e_j0f.c \
	msun/src/e_j1.c \
	msun/src/e_j1f.c \
	msun/src/e_jn.c \
	msun/src/e_jnf.c \
	msun/src/e_lgam1.c \
	msun/src/e_lgam2.c \
	msun/src/e_lgam3.c \
	msun/src/e_lgamma.c \
	msun/src/e_log10f.c \
	msun/src/e_logf.c \
	msun/src/e_pow.c \
	msun/src/e_powf.c \
	msun/src/e_rem1.c \
	msun/src/e_rem2.c \
	msun/src/e_rem_pi.c \
	msun/src/e_scalbf.c \
	msun/src/e_sinh.c \
	msun/src/e_sinhf.c \
	msun/src/e_sqrtf.c \
	msun/src/k_cos.c \
	msun/src/k_cosf.c \
	msun/src/k_rem1.c \
	msun/src/k_rem_pi.c \
	msun/src/k_sin.c \
	msun/src/k_sinf.c \
	msun/src/k_standa.c \
	msun/src/k_tan.c \
	msun/src/k_tanf.c \
	msun/src/s_asinh.c \
	msun/src/s_asinhf.c \
	msun/src/s_atanf.c \
	msun/src/s_cbrt.c \
	msun/src/s_cbrtf.c \
	msun/src/s_ceilf.c \
	msun/src/s_copy1.c \
	msun/src/s_cosf.c \
	msun/src/s_erf.c \
	msun/src/s_erff.c \
	msun/src/s_expm1.c \
	msun/src/s_expm1f.c \
	msun/src/s_fabs.c \
	msun/src/s_fabsf.c \
	msun/src/s_fini1.c \
	msun/src/s_floorf.c \
	msun/src/s_frexp.c \
	msun/src/s_frexpf.c \
	msun/src/s_ilogbf.c \
	msun/src/s_isnan.c \
	msun/src/s_isnanf.c \
	msun/src/s_ldexp.c \
	msun/src/s_ldexpf.c \
	msun/src/s_lib_ve.c \
	msun/src/s_log1pf.c \
	msun/src/s_logbf.c \
	msun/src/s_mather.c \
	msun/src/s_modf.c \
	msun/src/s_modff.c \
	msun/src/s_next1.c \
	msun/src/s_nextaf.c \
	msun/src/s_rintf.c \
	msun/src/s_scal1.c \
	msun/src/s_sign1.c \
	msun/src/s_signga.c \
	msun/src/s_sinf.c \
	msun/src/s_tanf.c \
	msun/src/s_tanh.c \
	msun/src/s_tanhf.c \
	msun/src/e_acos.c \
	msun/src/e_asin.c \
	msun/src/e_atan2.c \
	msun/src/e_exp.c \
	msun/src/e_fmod.c \
	msun/src/e_log.c \
	msun/src/e_log10.c \
	msun/src/e_remain.c \
	msun/src/e_scalb.c \
	msun/src/e_sqrt.c \
	msun/src/s_atan.c \
	msun/src/s_ceil.c \
	msun/src/s_copysi.c \
	msun/src/s_cos.c \
	msun/src/s_finite.c \
	msun/src/s_floor.c \
	msun/src/s_ilogb.c \
	msun/src/s_log1p.c \
	msun/src/s_logb.c \
	msun/src/s_rint.c \
	msun/src/s_scalbn.c \
	msun/src/s_signif.c \
	msun/src/s_sin.c \
	msun/src/s_tan.c \
	msun/src/w_acos.c \
	msun/src/w_acosf.c \
	msun/src/w_acosh.c \
	msun/src/w_acoshf.c \
	msun/src/w_asin.c \
	msun/src/w_asinf.c \
	msun/src/w_atan2.c \
	msun/src/w_atan2f.c \
	msun/src/w_atanh.c \
	msun/src/w_atanhf.c \
	msun/src/w_cabs.c \
	msun/src/w_cabsf.c \
	msun/src/w_cosh.c \
	msun/src/w_coshf.c \
	msun/src/w_drem.c \
	msun/src/w_dremf.c \
	msun/src/w_exp.c \
	msun/src/w_expf.c \
	msun/src/w_fmod.c \
	msun/src/w_fmodf.c \
	msun/src/w_gamf1.c \
	msun/src/w_gamma.c \
	msun/src/w_gamma_.c \
	msun/src/w_gammaf.c \
	msun/src/w_hypot.c \
	msun/src/w_hypotf.c \
	msun/src/w_j0.c \
	msun/src/w_j0f.c \
	msun/src/w_j1.c \
	msun/src/w_j1f.c \
	msun/src/w_jn.c \
	msun/src/w_jnf.c \
	msun/src/w_lgam1.c \
	msun/src/w_lgam2.c \
	msun/src/w_lgam3.c \
	msun/src/w_lgamma.c \
	msun/src/w_log.c \
	msun/src/w_log10.c \
	msun/src/w_log10f.c \
	msun/src/w_logf.c \
	msun/src/w_pow.c \
	msun/src/w_powf.c \
	msun/src/w_rem1.c \
	msun/src/w_remain.c \
	msun/src/w_scalb.c \
	msun/src/w_scalbf.c \
	msun/src/w_sinh.c \
	msun/src/w_sinhf.c \
	msun/src/w_sqrt.c \
	msun/src/w_sqrtf.c \

sources = \

asm_sources = \
	msun/i387/e_acos.s \
	msun/i387/e_asin.s \
	msun/i387/e_atan2.s \
	msun/i387/e_exp.s \
	msun/i387/e_fmod.s \
	msun/i387/e_log.s \
	msun/i387/e_log10.s \
	msun/i387/e_remain.s \
	msun/i387/e_scalb.s \
	msun/i387/e_sqrt.s \
	msun/i387/s_atan.s \
	msun/i387/s_ceil.s \
	msun/i387/s_copysi.s \
	msun/i387/s_cos.s \
	msun/i387/s_finite.s \
	msun/i387/s_floor.s \
	msun/i387/s_ilogb.s \
	msun/i387/s_log1p.s \
	msun/i387/s_logb.s \
	msun/i387/s_rint.s \
	msun/i387/s_scalbn.s \
	msun/i387/s_signif.s \
	msun/i387/s_sin.s \
	msun/i387/s_tan.s \

all: liblibc.a

clean:
	$(RM) *.o liblibc.a string/*.o stdlib/*.o ioformat/*.o machine/*.o msun/src/*.o msun/i387/*.o

liblibc.a: $(sources:.cc=.o) $(c_sources:.c=.o) $(asm_sources:.s=.o)
	ar cru $@ $?

%.o : %.s
	$(REDIR) $(AS) -x assembler-with-cpp $(OC_OPT) -c $< -o $@

%.o: %.c
	$(REDIR) $(CC) $(OC_OPT) -c $< -o $@

%.o: %.cc
	$(REDIR) $(CC) $(OCC_OPT) -c $< -o $@

